package com.jkzaixian.online;

import android.content.Intent;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.jkzaixian.online.video.VideoDetailActivity;

public class MyVideoModule extends ReactContextBaseJavaModule {

    public static final String REACTCLASSNAME = "MyVideoModule";
    private ReactApplicationContext mContext;

    public MyVideoModule(ReactApplicationContext reactContext) {
        super(reactContext);
        mContext = reactContext;
    }

    @Override
    public String getName() {
        return REACTCLASSNAME;
    }

    /**
     * 必须添加反射注解不然会报错
     * 这个方法就是ReactNative将要调用的方法，会通过此类名字调用
     */

    @ReactMethod
    public void callPlayMethod(String url, String title) {
        Intent intent = new Intent(mContext, VideoDetailActivity.class);
        intent.putExtra("url", url);
        intent.putExtra("title", title);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(intent);
    }

}
